﻿package mortal.game.view.friend
{
    import Message.Game.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.display.*;
    import flash.events.*;
    import flash.ui.*;
    import mortal.game.cache.*;
    import mortal.game.view.common.*;

    public class FriendGroupInfoSpr extends GSprite
    {
        private var _bg:ScaleBitmap;
        private var _addSpr:Sprite;
        private var _addImg:GBitmap;
        private var _plusSpr:Sprite;
        private var _plusImg:GBitmap;
        private var _listTypeLabel:GTextFiled;
        private var _listRoleNum:GTextFiled;
        private var _intimacyLabel:GTextFiled;
        private var _fightLabel:GTextFiled;
        private var _flag:int;

        public function FriendGroupInfoSpr()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._addSpr = UIFactory.sprite(0, 7, this);
            this._addImg = UIFactory.gBitmap("Add", 0, 0, this._addSpr);
            this._plusSpr = UIFactory.sprite(0, 7, this);
            this._plusImg = UIFactory.gBitmap("Plus", 0, 4, this._plusSpr);
            this._plusSpr.visible = false;
            this._listTypeLabel = UIFactory.gTextField("", 18 - 4, 3, 90, 20, this);
            this._listRoleNum = UIFactory.gTextField("[0/0]", 71 - 4, 3, 60, 20, this);
            this._intimacyLabel = UIFactory.gTextField(Language.getString(41226), 212 + 14, 3, 50, 20, this);
            this._fightLabel = UIFactory.gTextField(Language.getString(41227), 212 + 14, 3, 50, 20, this);
            this._fightLabel.visible = false;
            this.updateListType(0);
            this._addSpr.buttonMode = true;
            this._addSpr.mouseChildren = false;
            this._addSpr.addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this._addSpr.addEventListener(MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            this._plusSpr.buttonMode = true;
            this._plusSpr.mouseChildren = false;
            this._plusSpr.addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this._plusSpr.addEventListener(MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._addImg.dispose(param1);
            this._plusImg.dispose(param1);
            this._listTypeLabel.dispose(param1);
            this._listRoleNum.dispose(param1);
            this._intimacyLabel.dispose(param1);
            this._fightLabel.dispose(param1);
            this._addImg = null;
            this._plusImg = null;
            this._listTypeLabel = null;
            this._listRoleNum = null;
            this._intimacyLabel = null;
            this._fightLabel = null;
            this._addSpr.removeEventListener(MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this._addSpr.removeEventListener(MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            this._plusSpr.removeEventListener(MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this._plusSpr.removeEventListener(MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            return;
        }// end function

        public function updateListType(param1:int) : void
        {
            switch(param1)
            {
                case 0:
                {
                    if (this.flag == EFriendType._EFriendtypeIntimate)
                    {
                        this._listTypeLabel.text = Language.getString(41228);
                    }
                    else if (this.flag == EFriendType._EFriendTypeNormal)
                    {
                        this._listTypeLabel.text = Language.getString(41229);
                    }
                    this._intimacyLabel.visible = true;
                    this._listRoleNum.visible = true;
                    this._fightLabel.visible = false;
                    break;
                }
                case 1:
                {
                    this._listTypeLabel.text = Language.getString(41230);
                    this._intimacyLabel.visible = false;
                    this._listRoleNum.visible = false;
                    this._fightLabel.visible = true;
                    break;
                }
                case 2:
                {
                    this._listTypeLabel.text = Language.getString(41231);
                    this._intimacyLabel.visible = false;
                    this._listRoleNum.visible = false;
                    this._fightLabel.visible = false;
                    break;
                }
                case 3:
                {
                    this._listTypeLabel.text = Language.getString(41232);
                    this._intimacyLabel.visible = false;
                    this._listRoleNum.visible = false;
                    this._fightLabel.visible = false;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function updateRoleNum() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            switch(this._flag)
            {
                case EFriendType._EFriendtypeIntimate:
                {
                    _loc_1 = Cache.instance.friend.getCurrOnlineNum(EFriendType._EFriendtypeIntimate);
                    _loc_2 = Cache.instance.friend.closeFriendList.length;
                    this._listRoleNum.text = "[" + _loc_1 + "/" + _loc_2 + "]";
                    break;
                }
                case EFriendType._EFriendTypeNormal:
                {
                    _loc_3 = Cache.instance.friend.getCurrOnlineNum(EFriendType._EFriendTypeNormal);
                    _loc_4 = Cache.instance.friend.friendList.length;
                    this._listRoleNum.text = "[" + _loc_3 + "/" + _loc_4 + "]";
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function set flag(param1:int) : void
        {
            this._flag = param1;
            return;
        }// end function

        public function get flag() : int
        {
            return this._flag;
        }// end function

        public function switchBtnState(param1:Boolean) : void
        {
            if (param1)
            {
                this._addSpr.visible = false;
                this._plusSpr.visible = true;
            }
            else
            {
                this._addSpr.visible = true;
                this._plusSpr.visible = false;
            }
            return;
        }// end function

        private function onMouseOverHandler(event:MouseEvent) : void
        {
            Mouse.cursor = "button";
            return;
        }// end function

        private function onMouseOutHandler(event:MouseEvent) : void
        {
            Mouse.cursor = "auto";
            return;
        }// end function

        public function get addSpr() : Sprite
        {
            return this._addSpr;
        }// end function

        public function get plusSpr() : Sprite
        {
            return this._plusSpr;
        }// end function

    }
}
